﻿using DAL.DBManagers;
using System;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;

public partial class UserView : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //var menuliClicker = Master.FindControl("ScriptHolder") as Literal;
        //menuliClicker.Text = "<script>$('#liUsers').click();</script>";
        //if (menuli != null)
        //{
        //    menuli.Attributes.Remove("class");
        //    menuli.Attributes.Add("class", "selected");
        //}

    }

    protected void UserGirdView_RowDeleted(object sender, GridViewDeletedEventArgs e)
    {
        Response.Redirect(Request.Url.OriginalString);
    }

    protected void btnResetPassword_Click(object sender, EventArgs e)
    {
        using (UsersManager manager = new UsersManager())
        {
            var UserID = Guid.Parse((sender as Button).CommandArgument);

            var user = manager.Single(s => s.UserID == UserID);

            user.Password = HelperService.GetMd5Hash("Aa1@3456");

            manager.SaveChanges();
        }
    }
}